/**
 * 
 */
package stc.skymobi.fsm.util;

import java.util.UUID;

import stc.skymobi.fsm.ContextKeyFactory;
import stc.skymobi.util.IdentifyableOfInt;


/**
 * @author hp
 *
 */
public class IntKeyFactory implements ContextKeyFactory {

	private	UUID2IntDictionary	uuid2int;
	
	/**
	 * @return the uuid2int
	 */
	public UUID2IntDictionary getUuid2int() {
		return uuid2int;
	}

	/**
	 * @param uuid2int the uuid2int to set
	 */
	public void setUuid2int(UUID2IntDictionary uuid2int) {
		this.uuid2int = uuid2int;
	}

	public void removeKey(Object key) {
		if ( key instanceof UUID ) {
			uuid2int.removeByUUID((UUID)key);
		}
	}

	public Object transformToKey(Object event) {
		if ( event instanceof IdentifyableOfInt ) {
			int intval = ((IdentifyableOfInt)event).getIntIdentification();
			return	uuid2int.queryUUID(intval);
		}
		return null;
	}

}
